package com.enation.app.web.tag.member;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Component;

import com.enation.app.web.core.model.Member;
import com.enation.framework.context.webcontext.ThreadContextHolder;
import com.enation.framework.taglib.BaseFreeMarkerTag;

import freemarker.template.TemplateModelException;

/**
 * 
 * @function 会员登录标签
 * @author 闯哥
 * @time 2016年12月2日 下午10:04:55
 */
@Component
public class MemberLoginTag extends BaseFreeMarkerTag {

	@Override
	protected Object exec(Map params) throws TemplateModelException {

		HttpServletRequest request = ThreadContextHolder.getHttpRequest();
		HttpSession session = request.getSession();

		Member member = (Member) session.getAttribute("member");

		if (member != null) {
			return member;
		}

		return "";
	}

}
